package com.hsh.controller;

import com.alibaba.fastjson.JSON;
import com.hsh.bean.Admin;
import com.hsh.bean.Comment;
import com.hsh.bean.Message;
import com.hsh.bean.User;
import com.hsh.service.AdminService;
import com.hsh.service.CommentService;
import com.hsh.service.UserService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/admin")
public class AdminRestController {

    @Resource
    private CommentService commentService;

    @RequestMapping("/update-data")
    public String update(Comment comment) {
        comment.setCDate(new Date());

        Integer update = commentService.update(comment);
        Message msg = new Message();
        msg.setState(update - 1);
        msg.setResult(update == 1 ? "修改成功" : "修改失败");
        return JSON.toJSONString(msg);

    }

}
